package com.demo;

import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

import java.util.Arrays;
import java.util.List;

public class DriverConfig {

    public WebDriver getChromeDriverSystem(){
        System.setProperty("webdriver.chrome.driver", "C:\\Users\\15328\\.cache\\selenium\\chromedriver\\win64\\138.0.7204.157\\chromedriver.exe");

        ChromeOptions options = new ChromeOptions();

        options.addArguments("--disable-blink-features=AutomationControlled");

        options.setExperimentalOption("excludeSwitches", Arrays.asList("enable-automation"));

        options.addArguments("--remote-allow-origins=*");

        return new ChromeDriver(options);
    }

    public WebDriver getChromeDriverSystem(List<String> conf){
        System.setProperty("webdriver.chrome.driver", "C:\\Users\\15328\\.cache\\selenium\\chromedriver\\win64\\138.0.7204.157\\chromedriver.exe");

        ChromeOptions options = new ChromeOptions();

        options.addArguments("--remote-allow-origins=*");

        for(String conf1 : conf) {
            options.addArguments(conf1);
        }

        return  new ChromeDriver(options);
    }

    public WebDriver getChromeDriver(List<String> conf){
        WebDriverManager.chromedriver().setup();

        ChromeOptions options = new ChromeOptions();

        options.addArguments("--remote-allow-origins=*");

        for (String conf1 : conf) {
            options.addArguments(conf1);
        }

        return  new ChromeDriver(options);
    }

    public WebDriver getChromeDriver(){
        WebDriverManager.chromedriver().setup();

        ChromeOptions options = new ChromeOptions();

        options.addArguments("--remote-allow-origins=*");

        return  new ChromeDriver(options);
    }
}
